package com.example.cola.common.error;

import java.io.Serializable;

/**
 * @author fenglin
 * @date 2022/8/14
 */
public class ErrorCode implements Serializable {

	/**
	 * 错误码枚举
	 */
	private ErrorCodeEnum errorCodeEnum;

	/**
	 * 错误信息
	 */
	private String errMsg;

	public ErrorCode(ErrorCodeEnum errorCodeEnum) {
		this.errorCodeEnum = errorCodeEnum;
		this.errMsg = errorCodeEnum.getErrorMessage();
	}

	public ErrorCode(ErrorCodeEnum errorCodeEnum, String errMsg) {
		this.errorCodeEnum = errorCodeEnum;
		this.errMsg = errMsg;
	}
//
//	/**
//	 * 获取完整错误码
//	 *
//	 * @return
//	 */
	public String getCode() {
		return "";
//		return source + "-" + errorCodeEnum.getDomain() + "-" + errorMessage.getCode();
	}

	public static ErrorCode of(ErrorCodeEnum codeEnum) {
		return new ErrorCode(codeEnum);
	}

	public static ErrorCode of(ErrorCodeEnum codeEnum, String errMsg) {
		return new ErrorCode(codeEnum, errMsg);
	}

//	@Override
//	public String toString() {
//		return getCode() + " (" + () + ")";
//	}


	public String getErrMsg() {
		return errMsg;
	}

}
